Skip to content

refactor(rust): share test scaffolding via mergify-test-support crate#1439

Open
jd wants to merge 1 commit into
devs/jd/worktree-rust-port/accept-debug-rust-binary-actually-toggle-python--62ac941dfrom
devs/jd/worktree-rust-port/share-test-scaffolding-via-mergify-test-support--f9d688cd
Open

refactor(rust): share test scaffolding via mergify-test-support crate#1439
jd wants to merge 1 commit into
devs/jd/worktree-rust-port/accept-debug-rust-binary-actually-toggle-python--62ac941dfrom
devs/jd/worktree-rust-port/share-test-scaffolding-via-mergify-test-support--f9d688cd

Conversation

@jd
Copy link
Copy Markdown
Member

@jd jd commented May 19, 2026

Every command crate's test module re-rolled the same ~30 LOC of
SharedBytes / SharedWriter / Captured / make_output glue —
about 350 LOC of pure boilerplate across 15 files, drifting over
time (some Captured had stderr, some didn't; one file even
carried a _stderr_accessor_lives dead-code stub just to silence
the resulting warning).

Extract the canonical version into a new mergify-test-support
crate that other crates pull in as a dev-dependencies. The new
Captured API exposes human() / new(mode) constructors and
stdout() / stderr() accessors, so the common pattern shrinks
from a 12-line String::from_utf8(cap.stdout.lock().unwrap().clone())
to let s = cap.stdout().

Net -418 / +114 lines across the workspace. Behavior unchanged;
all 233 tests pass.

The crate is publish = false and only ever appears under
[dev-dependencies], so the test-only types never leak into a
production build.

Co-Authored-By: Claude Opus 4.7 noreply@anthropic.com

Depends-On: #1464

@jd
Copy link
Copy Markdown
Member Author

jd commented May 19, 2026

This pull request is part of a Mergify stack:

# Pull Request Link
1 fix(cli): accept --debug on the Rust binary and actually toggle it in Python #1464
2 refactor(rust): share test scaffolding via mergify-test-support crate #1439 👈
3 refactor(core): introduce CommandContext for the queue+freeze prelude #1441
4 refactor(ci): consolidate the CI-env scrubber into a shared testing module #1442
5 refactor: drop stale Phase X.Y doc markers and one inline color branch #1443
6 refactor(tui): share StyledGlyph across queue show/status renderers #1444
7 refactor(queue): drop indexmap, group_by_scope returns a Vec<(K, V)> #1445
8 refactor(ci): swap uuid for getrandom in the GHA heredoc delimiter #1446
9 refactor(config): standardize the workspace on serde_yaml_ng for YAML parsing #1447
10 test(ci): add live smoke test for ci scopes select-all path #1460
11 feat(rust): port ci scopes to native Rust #1461
12 feat(ci): parse JUnit XML reports in native Rust #1465
13 feat(ci): encode JUnit cases as OTLP and upload to Mergify CI Insights #1466
14 feat(ci): promote ci junit-process from shim to native Rust #1467
15 feat(ci): promote ci junit-upload from shim to native as a deprecated alias #1468
16 fix(ci): prefer GitHub Actions PR-event head SHA over GITHUB_SHA #1469

@mergify
Copy link
Copy Markdown
Contributor

mergify Bot commented May 19, 2026

Merge Protections

Your pull request matches the following merge protections and will not be merged until they are valid.

🔴 ⛓️ Depends-On Requirements

Waiting for

This rule is failing.

Requirement based on the presence of Depends-On in the body of the pull request

🔴 👀 Review Requirements

Waiting for

  • #approved-reviews-by>=2
This rule is failing.
  • any of:
    • #approved-reviews-by>=2
    • author = dependabot[bot]
    • author = mergify-ci-bot
    • author = renovate[bot]

🔴 🔎 Reviews

Waiting for

  • #review-requested = 0
This rule is failing.
  • #review-requested = 0
  • #changes-requested-reviews-by = 0
  • #review-threads-unresolved = 0

🟢 🤖 Continuous Integration

Wonderful, this rule succeeded.
  • all of:
    • check-success=ci-gate

🟢 Enforce conventional commit

Wonderful, this rule succeeded.

Make sure that we follow https://www.conventionalcommits.org/en/v1.0.0/

  • title ~= ^(fix|feat|docs|style|refactor|perf|test|build|ci|chore|revert|ui)(?:\(.+\))?:

🟢 📕 PR description

Wonderful, this rule succeeded.
  • body ~= (?ms:.{48,})

@mergify mergify Bot requested a review from a team May 19, 2026 12:21
@jd jd marked this pull request as ready for review May 19, 2026 12:49
@jd jd force-pushed the devs/jd/worktree-rust-port/dedupe-emit-helper-boilerplate-across-cmd-crates--ed32eef9 branch from 721eacd to a6bf822 Compare May 19, 2026 13:04
@jd jd force-pushed the devs/jd/worktree-rust-port/share-test-scaffolding-via-mergify-test-support--f9d688cd branch from 32628b4 to d7feae3 Compare May 19, 2026 13:04
@jd jd temporarily deployed to func-tests-live May 19, 2026 13:04 — with GitHub Actions Inactive
@jd jd temporarily deployed to func-tests-live May 19, 2026 13:04 — with GitHub Actions Inactive
@jd jd temporarily deployed to func-tests-live May 19, 2026 13:04 — with GitHub Actions Inactive
@jd
Copy link
Copy Markdown
Member Author

jd commented May 19, 2026

Revision history

# Type Changes Reason Date
1 initial 32628b4 2026-05-19 13:04 UTC
2 content 32628b4 → d7feae3 2026-05-19 13:04 UTC
3 rebase d7feae3 → bdea5bb (rebase only) 2026-05-19 14:15 UTC
4 rebase bdea5bb → 64bc36f (rebase only) 2026-05-20 08:42 UTC
5 rebase 64bc36f → 7d303a1 (rebase only) 2026-05-20 09:05 UTC
6 rebase 7d303a1 → e8a93b3 (rebase only) 2026-05-21 07:25 UTC
7 rebase e8a93b3 → ac60092 (rebase only) 2026-05-21 07:56 UTC
8 rebase ac60092 → 20762f6 (rebase only) 2026-05-21 12:39 UTC
9 content 20762f6 → 53fc9fd (raw) 2026-05-22 07:10 UTC
10 rebase 53fc9fd → d62619b (rebase only) 2026-05-22 14:40 UTC
11 rebase d62619b → d61820b (rebase only) 2026-05-27 07:53 UTC
12 content d61820b → 32a71f8 (raw) 2026-05-27 08:27 UTC

@mergify mergify Bot had a problem deploying to Mergify Merge Protections May 19, 2026 13:04 Failure
@jd jd force-pushed the devs/jd/worktree-rust-port/share-test-scaffolding-via-mergify-test-support--f9d688cd branch from d7feae3 to bdea5bb Compare May 19, 2026 14:14
@jd jd force-pushed the devs/jd/worktree-rust-port/dedupe-emit-helper-boilerplate-across-cmd-crates--ed32eef9 branch from a6bf822 to ac72c27 Compare May 19, 2026 14:14
@jd jd temporarily deployed to func-tests-live May 19, 2026 14:15 — with GitHub Actions Inactive
@mergify mergify Bot had a problem deploying to Mergify Merge Protections May 19, 2026 14:15 Failure
@jd jd force-pushed the devs/jd/worktree-rust-port/share-test-scaffolding-via-mergify-test-support--f9d688cd branch from 53fc9fd to d62619b Compare May 22, 2026 14:40
@jd jd temporarily deployed to func-tests-live May 22, 2026 14:40 — with GitHub Actions Inactive
@jd jd temporarily deployed to func-tests-live May 22, 2026 14:40 — with GitHub Actions Inactive
@mergify mergify Bot had a problem deploying to Mergify Merge Protections May 22, 2026 14:40 Failure
Base automatically changed from devs/jd/worktree-rust-port/dedupe-emit-helper-boilerplate-across-cmd-crates--ed32eef9 to main May 26, 2026 15:51
@mergify
Copy link
Copy Markdown
Contributor

mergify Bot commented May 26, 2026

@jd this pull request is now in conflict 😩

@mergify mergify Bot added the conflict label May 26, 2026
Copilot AI review requested due to automatic review settings May 27, 2026 07:53
@jd jd force-pushed the devs/jd/worktree-rust-port/share-test-scaffolding-via-mergify-test-support--f9d688cd branch from d62619b to d61820b Compare May 27, 2026 07:53
@jd jd changed the base branch from main to devs/jd/worktree-rust-port/accept-debug-rust-binary-actually-toggle-python--62ac941d May 27, 2026 07:53
@jd jd temporarily deployed to func-tests-live May 27, 2026 07:53 — with GitHub Actions Inactive
@mergify mergify Bot had a problem deploying to Mergify Merge Protections May 27, 2026 07:53 Failure
@mergify mergify Bot removed the conflict label May 27, 2026
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors the Rust workspace’s test code by extracting repeated output-capture scaffolding (shared buffers + Write adapters + helpers) into a dedicated mergify-test-support crate that is only used via dev-dependencies, reducing boilerplate and keeping test-only types out of production builds.

Changes:

  • Added a new crates/mergify-test-support crate providing Captured, SharedBytes, and SharedWriter for consistent stdout/stderr capture in tests.
  • Updated multiple command-crate test modules to use mergify_test_support::Captured instead of local duplicated implementations.
  • Wired the new crate into relevant crates’ dev-dependencies and updated Cargo.lock.

Reviewed changes

Copilot reviewed 20 out of 21 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
crates/mergify-test-support/src/lib.rs Introduces shared capture types (Captured, SharedWriter) for Rust command tests.
crates/mergify-test-support/Cargo.toml Defines the new non-published test-support crate and its dependency on mergify-core.
crates/mergify-queue/src/unpause.rs Replaces local capture scaffolding in tests with Captured.
crates/mergify-queue/src/status.rs Replaces local capture scaffolding in tests with Captured.
crates/mergify-queue/src/show.rs Replaces local capture scaffolding in tests with Captured and removes dead-code stderr accessor workaround.
crates/mergify-queue/src/pause.rs Replaces local capture scaffolding in tests with Captured.
crates/mergify-queue/Cargo.toml Adds mergify-test-support under dev-dependencies.
crates/mergify-freeze/src/update.rs Replaces local capture scaffolding in tests with Captured.
crates/mergify-freeze/src/list.rs Replaces local capture scaffolding in tests with Captured.
crates/mergify-freeze/src/delete.rs Replaces local capture scaffolding in tests with Captured.
crates/mergify-freeze/src/create.rs Replaces local capture scaffolding in tests with Captured.
crates/mergify-freeze/Cargo.toml Adds mergify-test-support under dev-dependencies.
crates/mergify-config/src/validate.rs Replaces local capture scaffolding in tests with Captured.
crates/mergify-config/src/simulate.rs Replaces local capture scaffolding in tests with Captured.
crates/mergify-config/Cargo.toml Adds mergify-test-support under dev-dependencies.
crates/mergify-ci/src/scopes_send.rs Replaces local capture scaffolding in tests with Captured.
crates/mergify-ci/src/queue_metadata.rs Replaces local capture scaffolding in tests with Captured.
crates/mergify-ci/src/queue_info.rs Replaces local capture scaffolding in tests with Captured.
crates/mergify-ci/src/git_refs.rs Replaces local capture scaffolding in tests with Captured.
crates/mergify-ci/Cargo.toml Adds mergify-test-support under dev-dependencies.
Cargo.lock Records the new crate and dependency edges in the workspace lockfile.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread crates/mergify-test-support/src/lib.rs Outdated
Every command crate's test module re-rolled the same ~30 LOC of
`SharedBytes` / `SharedWriter` / `Captured` / `make_output` glue —
about 350 LOC of pure boilerplate across 15 files, drifting over
time (some `Captured` had `stderr`, some didn't; one file even
carried a `_stderr_accessor_lives` dead-code stub just to silence
the resulting warning).

Extract the canonical version into a new `mergify-test-support`
crate that other crates pull in as a `dev-dependencies`. The new
`Captured` API exposes `human()` / `new(mode)` constructors and
`stdout()` / `stderr()` accessors, so the common pattern shrinks
from a 12-line `String::from_utf8(cap.stdout.lock().unwrap().clone())`
to `let s = cap.stdout()`.

Net `-418 / +114` lines across the workspace. Behavior unchanged;
all 233 tests pass.

The crate is `publish = false` and only ever appears under
`[dev-dependencies]`, so the test-only types never leak into a
production build.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Change-Id: If9d688cdaf55360ba90f386d2020b52346c19b28
@jd jd force-pushed the devs/jd/worktree-rust-port/accept-debug-rust-binary-actually-toggle-python--62ac941d branch from 83fc4d3 to fe3d611 Compare May 27, 2026 08:27
@jd jd force-pushed the devs/jd/worktree-rust-port/share-test-scaffolding-via-mergify-test-support--f9d688cd branch from d61820b to 32a71f8 Compare May 27, 2026 08:27
@jd jd temporarily deployed to func-tests-live May 27, 2026 08:27 — with GitHub Actions Inactive
@jd jd temporarily deployed to func-tests-live May 27, 2026 08:27 — with GitHub Actions Inactive
@mergify mergify Bot had a problem deploying to Mergify Merge Protections May 27, 2026 08:28 Failure
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants